package com.csu.pet.demo.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.csu.pet.demo.domain.divide.OrderStatus;
import com.csu.pet.demo.domain.divide.Orders;
import com.csu.pet.demo.persistence.OrderStatusMapper;
import com.csu.pet.demo.persistence.OrdersMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
@Service
public class OrderService {
    @Autowired
    private OrdersMapper ordersMapper;
    @Autowired
    private OrderStatusMapper orderStatusMapper;
    //根据order id获得order
    public Orders getOrders(int orderId){
        return ordersMapper.selectById(orderId);
    }
    //根据username 获得order list
    public List<Orders> getOrdersByUsername(String username){
        QueryWrapper<Orders> queryWrappe = new QueryWrapper<>();
        List<Orders> orderList = ordersMapper.selectList(queryWrappe.eq("userid",username));
        return orderList;
    }
    //插入order
    public void insertOrder(Orders orders) {
        ordersMapper.insert(orders);
    }
    //插入order status (另一个mapper)
    public void insertOrderStatus(OrderStatus orderStatus) {
        orderStatusMapper.insert(orderStatus);
    }
}

